package com.xl.basic.entity;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;

/**
 * 登录异常
 * {@code @Author:钟勇}
 * {@code @Date：Create in 2023/5/25 11:22}
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class ResultException extends RuntimeException {

    @NonNull
    private Integer code;

    public ResultException() {
        super(ResultEnums.Exception.getMessage());
        this.code = ResultEnums.Exception.getCode();
    }

    public ResultException(String message) {
        super(message);
        this.code = ResultEnums.Exception.getCode();
    }

    public ResultException(@NonNull Integer code, String message) {
        super(message);
        this.code = code;
    }

    public <T> ResultException(@NonNull Result<T> result) {
        super(result.getMessage());
        this.code = result.getCode();
    }

    public ResultException(@NonNull ResultEnums result) {
        super(result.getMessage());
        this.code = result.getCode();
    }
}
